/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import GUI.Admin.*;
import java.awt.BorderLayout;
import java.awt.Label;
import javax.swing.ActionMap;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import org.jdesktop.application.Action;
import org.jdesktop.application.SingleFrameApplication;

/**
 *
 * @author Dang Nhung
 */
public class LeftPanel_Admin extends javax.swing.JPanel {

    JScrollPane scrollPane;
    SingleFrameApplication singleApplication;
    JComponent singleOpenContainer;
    // Control Admin_FilmTypeManage component
    JPanel singleAdminFilmTypeManage;
    // Control Admin_RoomManage component
    JPanel singleAdminRoomManage;
    // Control Admin_ShowtimesManage component
    JPanel singleAdminShowtimesManage;
    // Control Admin_ShowtimesManage component
    JPanel singleAdminSeatsManage;
    // Control Admin_FilmManage component
    JPanel singleAdminFilmManage;
    // Control Admin_FilmScheduleManage component
    JPanel singleAdminFilmScheduleManage;
    // Control Admin_ImageMange component
    JPanel singleAdminImageManage;
    

    /**
     * Creates new form Admin_LeftPanel
     */
    public LeftPanel_Admin(SingleFrameApplication app, JComponent container) {
       
        this.singleOpenContainer = container;// Fixed container component must be jPanel
        this.singleApplication = app;// Asign context variable.
        initComponents();// Render layout component.
        ActionMap map = app.getContext().getActionMap(this);// Define Action Resources.
        // Bind action openFilmTypeManager from the above resources.        
        this.jbtnfilmtypemanage.setAction(map.get("FilmTypeManager"));
        this.jtbnroommanage.setAction(map.get("RoomManager"));
        this.jbtnshowtimesmanage.setAction(map.get("ShowtimesManager"));
        this.jbtnseatmanage.setAction(map.get("SeatManager"));
        this.jbtnfilmmanage.setAction(map.get("FilmManager"));
        this.jbtnfilmschedulemanage.setAction(map.get("FilmScheduleManager"));
        this.jbtnimagemanage.setAction(map.get("ImageManager"));
       
    }

    protected boolean VisibleChildContainer() {
        if (this.singleOpenContainer == null || this.singleOpenContainer.getComponentCount() < 1) {
            return false;
        }
        int countComponent = this.singleOpenContainer.getComponentCount();
        for (int i = 0; i < countComponent; i++) {
            this.singleOpenContainer.getComponent(i).setVisible(false);
        }
        return true;
    }

    /**
     * Implements action openFilmTypeManager
     *
     */
    @Action
    public void FilmTypeManager() {
        //Hasn't container component
        if (this.singleOpenContainer == null) {
            return;
        }
        VisibleChildContainer();
//        singleAdminFilmTypeManage = (singleAdminFilmTypeManage == null) ? new Admin_FilmTypeManage() : singleAdminFilmTypeManage;
//        this.singleOpenContainer.add(singleAdminFilmTypeManage, BorderLayout.CENTER);
//        singleAdminFilmTypeManage.setVisible(true);
//        this.singleApplication.getMainFrame().pack();
        if (singleAdminFilmTypeManage == null) {
            singleAdminFilmTypeManage = new Admin_FilmTypeManage();
            this.singleOpenContainer.add(singleAdminFilmTypeManage, BorderLayout.CENTER);
        }
        singleAdminFilmTypeManage.setVisible(true);
        this.singleApplication.getMainFrame().pack();
    }

    /*
     Edit by hnmtuan on 23/04/2012
     */
    @Action
    public void RoomManager() {
        //Hasn't container component
        if (this.singleOpenContainer == null) {return;}
        VisibleChildContainer();        
        if (singleAdminRoomManage == null) {
            singleAdminRoomManage = new Admin_RoomManage();
            this.singleOpenContainer.add(singleAdminRoomManage, BorderLayout.CENTER);
        }
        singleAdminRoomManage.setVisible(true);
        this.singleApplication.getMainFrame().pack();
    }

    @Action
    public void ShowtimesManager() {
        //Hasn't container component
        if (this.singleOpenContainer == null) {
            return;
        }
        singleAdminShowtimesManage = (singleAdminShowtimesManage == null) ? new Admin_ShowtimesManage() : singleAdminShowtimesManage;
        this.singleOpenContainer.add(singleAdminShowtimesManage, BorderLayout.CENTER);
        singleAdminShowtimesManage.setVisible(true);
        this.singleApplication.getMainFrame().pack();

    }

    @Action
    public void SeatManager() {
        //Hasn't container component
        if (this.singleOpenContainer == null) {
            return;
        }
        singleAdminSeatsManage = (singleAdminSeatsManage == null) ? new Admin_SeatManage() : singleAdminSeatsManage;
        this.singleOpenContainer.add(singleAdminSeatsManage, BorderLayout.CENTER);
        singleAdminSeatsManage.setVisible(true);
        this.singleApplication.getMainFrame().pack();
    }

    @Action
    public void FilmManager() {
        //Hasn't container component
        if (this.singleOpenContainer == null) {
            return;
        }
        VisibleChildContainer();
        if (singleAdminFilmManage == null) {
            singleAdminFilmManage = new Admin_FilmManage();
            this.singleOpenContainer.add(singleAdminFilmManage, BorderLayout.CENTER);
        }
        this.singleAdminFilmManage.setVisible(true);
        this.singleApplication.getMainFrame().pack();
    }

    @Action
    public void FilmScheduleManager() {
        //Hasn't container component
        if (this.singleOpenContainer == null) {
            return;
        }
        singleAdminFilmScheduleManage = (singleAdminFilmScheduleManage == null) ? new Admin_FilmScheduleManage() : singleAdminFilmScheduleManage;
        this.singleOpenContainer.add(singleAdminFilmScheduleManage, BorderLayout.CENTER);
        singleAdminFilmScheduleManage.setVisible(true);
        this.singleApplication.getMainFrame().pack();
    }

    @Action 
    public void ImageManager(){
           //Hasn't container component
        if (this.singleOpenContainer == null) {return;}
        VisibleChildContainer();        
        if (singleAdminImageManage == null) {
            singleAdminImageManage = new Admin_RoomManage();
            this.singleOpenContainer.add(singleAdminImageManage, BorderLayout.CENTER);
        }
        singleAdminImageManage.setVisible(true);
        this.singleApplication.getMainFrame().pack();
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToggleButton1 = new javax.swing.JToggleButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel1 = new javax.swing.JPanel();
        jbtnfilmmanage = new javax.swing.JButton();
        jbtnseatmanage = new javax.swing.JButton();
        jbtnimagemanage = new javax.swing.JButton();
        jtbnroommanage = new javax.swing.JButton();
        jbtnfilmtypemanage = new javax.swing.JButton();
        jbtnshowtimesmanage = new javax.swing.JButton();
        jbtnfilmschedulemanage = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        jToggleButton1.setText("jToggleButton1");

        setPreferredSize(new java.awt.Dimension(256, 691));

        jPanel1.setPreferredSize(new java.awt.Dimension(256, 691));

        jbtnfilmmanage.setBackground(new java.awt.Color(223, 240, 240));
        jbtnfilmmanage.setFont(new java.awt.Font("Arial", 1, 13));
        jbtnfilmmanage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/BPT_Images/film_icon.png"))); // NOI18N
        jbtnfilmmanage.setText("Film Manage");
        jbtnfilmmanage.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jbtnfilmmanage.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jbtnfilmmanage.setPreferredSize(new java.awt.Dimension(250, 39));

        jbtnseatmanage.setBackground(new java.awt.Color(223, 240, 240));
        jbtnseatmanage.setFont(new java.awt.Font("Arial", 1, 13));
        jbtnseatmanage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/BPT_Images/Seat_icon.png"))); // NOI18N
        jbtnseatmanage.setText("Seat Manage");
        jbtnseatmanage.setToolTipText("");
        jbtnseatmanage.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);

        jbtnimagemanage.setBackground(new java.awt.Color(223, 240, 240));
        jbtnimagemanage.setFont(new java.awt.Font("Arial", 1, 13));
        jbtnimagemanage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/BPT_Images/image_icon.jpg"))); // NOI18N
        jbtnimagemanage.setText("Image Manage");
        jbtnimagemanage.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);

        jtbnroommanage.setBackground(new java.awt.Color(223, 240, 240));
        jtbnroommanage.setFont(new java.awt.Font("Arial", 1, 13));
        jtbnroommanage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/BPT_Images/room_icon.jpg"))); // NOI18N
        jtbnroommanage.setText("Room Manage");
        jtbnroommanage.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);

        jbtnfilmtypemanage.setBackground(new java.awt.Color(223, 240, 240));
        jbtnfilmtypemanage.setFont(new java.awt.Font("Arial", 1, 13));
        jbtnfilmtypemanage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/BPT_Images/filmtype_icon.jpg"))); // NOI18N
        jbtnfilmtypemanage.setText("Film Type Manage");
        jbtnfilmtypemanage.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);

        jbtnshowtimesmanage.setBackground(new java.awt.Color(223, 240, 240));
        jbtnshowtimesmanage.setFont(new java.awt.Font("Arial", 1, 13));
        jbtnshowtimesmanage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/BPT_Images/showtime_icon.png"))); // NOI18N
        jbtnshowtimesmanage.setText("Showtimes Manage");
        jbtnshowtimesmanage.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);

        jbtnfilmschedulemanage.setBackground(new java.awt.Color(223, 240, 240));
        jbtnfilmschedulemanage.setFont(new java.awt.Font("Arial", 1, 13));
        jbtnfilmschedulemanage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/BPT_Images/filmschedule_icon.gif"))); // NOI18N
        jbtnfilmschedulemanage.setText("Film Schedule Manage");
        jbtnfilmschedulemanage.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jbtnfilmschedulemanage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jbtnshowtimesmanage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jbtnfilmtypemanage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jtbnroommanage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jbtnimagemanage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jbtnseatmanage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jbtnfilmmanage, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addContainerGap(33, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jbtnfilmmanage, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtnseatmanage, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtnimagemanage, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jtbnroommanage, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtnfilmtypemanage, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtnshowtimesmanage, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtnfilmschedulemanage, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(427, 427, 427))
        );

        jScrollPane1.setViewportView(jPanel1);

        jLabel1.setFont(new java.awt.Font("Arial", 1, 16));
        jLabel1.setText("Function Name");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 31, Short.MAX_VALUE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 472, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(187, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToggleButton jToggleButton1;
    private javax.swing.JButton jbtnfilmmanage;
    private javax.swing.JButton jbtnfilmschedulemanage;
    private javax.swing.JButton jbtnfilmtypemanage;
    private javax.swing.JButton jbtnimagemanage;
    private javax.swing.JButton jbtnseatmanage;
    private javax.swing.JButton jbtnshowtimesmanage;
    private javax.swing.JButton jtbnroommanage;
    // End of variables declaration//GEN-END:variables
}
